#!/usr/bin/python
# -*-coding: UTF-8 -*-
"""
# Time: 2021/10/31 21:41
# @Author: 修养
# @Project_name: PROJECT_NAME
"""
name = '青云, 乐山'
name_lists = name.split(',')
print('按逗号分隔，转为list:', name_lists)
str_s = '  Hello World! '
print('原始字符串：', str_s)
print('去掉首尾空格：', str_s.strip())
print('~~~~~~~2、字符串的搜索和替换~~~~~~~~~')
str_s = 'I like mike'
print('原始字符串：', str_s)
print('统计字符ke个数：', str_s.count('ke'))
print('查找ke,返回下标多个时，返回第一个，未查到返回-1: ', str_s.find('ke'))
print('查找ke,返回下标多个时，返回第一个，未查到抛出异常: ', str_s.index('ke'))
print('字符串替换：', str_s.replace('mike', 'apples'))
desc_str = "名字是{name}，年龄是{age}"
print('字符串格式化：', desc_str.format(name='小米', age='12'))
print('~~~~~~~~~~~~~3、字符串的测试和替换函数~~~~~~~~~~~~~~')
data_str = 'UserPassword'
print('字符串以User开头: ', data_str.startswith('User'))
print('字符串以Word开头: ', data_str.endswith('Word'))
# 字符串链接：join()
lists = ['Hello', 'World!']
str_s = ' '.join(lists)
print('data类型：str、dict、list、不能是：int: ', str_s)
str_1 = 'Hello'
str_2 = 'World!'
str_s = str_1 + ' ' + str_2
print('拼接后的字符串：', str_s)